
import GroupAPI from '../api/group.js';

export const Group={
   state:{
      grouplist:[],
      group_total_count:0,
      groupinfo:[],
   },
   mutations:{
      setGroupList(state,list){
          state.grouplist=list;
      },
      setGroupTotalCount(state,total_count){
          state.group_total_count=total_count;
      },
      setGroupInfo(state,info){
          state.groupinfo=info;
      }
   },
   actions:{
      loadGroupList(context,data){
          GroupAPI.getGroupList(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setGroupList',response.data.data.list);
                  context.commit('setGroupTotalCount',response.data.data.total_count);
              }
          })
      },
      //获取详情
      loadGroupInfo(context,data){
          GroupAPI.getGroupInfo(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setGroupInfo',response.data.info);
              }
          })
      }
   },
   getters:{
      getGroupList:state =>{
         return state.grouplist
      },
      getGroupTotalCount: state =>{
         return state.group_total_count
      },
      getGroupInfo:state => {
          return state.groupinfo;
      }
   }
}
